//
//  LDMyResumeCellEduInAll_Row.swift
//  DingDongZP
//
//  Created by LeMac on 16/12/29.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

import UIKit

class LDMyResumeCellEduInAll_Row: UIView {

    var eduOrga:UILabel?
    var eduOrgaTime:UILabel?
    var eduSpecial:UILabel?
    
    var dotView:UIImageView?
    var divideLine:UIView?
    
    var model:DDMyResumeEduexperience? {
        didSet{
            
            updateFrame()
        }
    }
    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setDefaultContent()
        setupFrame()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func updateFrame() {
        
        eduOrga?.text = model?.institutename
        eduOrgaTime?.text = "\((model?.startdate)! as String) - \((model?.enddate)! as String)"
        eduSpecial?.text = "\(model!.majortitle) | \(model!.edu)"
        
        
        
        
        
        
    }
    
    func setDefaultContent() {
        
        eduOrga = UILabel.setDetailsLab("XXXX学校", fontSize: 14, titleColor: LDFontColor.DeepGray,Alignment: nil)
        eduOrgaTime = UILabel.setDetailsLab("2011 - 2011", fontSize: 14, titleColor: LDFontColor.DeepGray,Alignment: .Left)
        eduSpecial = UILabel.setDetailsLab("专业名称 | 学位", fontSize: 14, titleColor: LDFontColor.DeepGray,Alignment: nil)
        
        dotView = UIImageView(image: UIImage(named: "green_dot"))
        divideLine = UIView()
        divideLine?.backgroundColor = LDLineColorLightGray
        
        addSubview(eduOrga!)
        addSubview(eduOrgaTime!)
        addSubview(eduSpecial!)
        
        addSubview(dotView!)
        addSubview(divideLine!)
    }
    
    func setupFrame() {
        
        dotView?.snp_makeConstraints(closure: { (make) in
            
            make.top.equalTo(0)//.offset(LDMargin_V*3)
            make.left.equalTo(0)
            make.size.equalTo(CGSizeMake(10, 10))
        })
        
        divideLine?.snp_makeConstraints(closure: { (make) in
            
            make.top.equalTo(dotView!.snp_bottom)
            make.centerX.equalTo(dotView!)
            make.bottom.equalTo(0)
            make.width.equalTo(0.5)
        })
        
        eduOrgaTime?.snp_makeConstraints(closure: { (make) in
            
            make.left.equalTo(dotView!.snp_right).offset(LDMargin_V*2)
            make.right.equalTo(-LDMargin_V)
            make.centerY.equalTo(dotView!)
            make.height.equalTo(25)
            
        })
        
        eduOrga?.snp_makeConstraints(closure: { (make) in
            
            make.top.equalTo(eduOrgaTime!.snp_bottom).offset(LDMargin_V)
            make.left.height.right.equalTo(eduOrgaTime!)
            
        })
        
        eduSpecial?.snp_makeConstraints(closure: { (make) in
            
            make.top.equalTo(eduOrga!.snp_bottom).offset(LDMargin_V)
            make.left.height.right.equalTo(eduOrgaTime!)
        })
    }
    
}
